#include "InputEventReceiver.h"
//------------------------------------------------------------------------
// Konstruktor
//------------------------------------------------------------------------
InputEventReceiver::InputEventReceiver()
{
	for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
		KeyIsDown[i] = false;
}
//------------------------------------------------------------------------
// Destruktor
//------------------------------------------------------------------------
InputEventReceiver::~InputEventReceiver()
{
}
//------------------------------------------------------------------------
// Methoden
//------------------------------------------------------------------------
bool InputEventReceiver::OnEvent(const SEvent& event)
{
	if ( event.EventType == irr::EET_GUI_EVENT )
	{
		if ( event.GUIEvent.EventType ==  EGET_ELEMENT_CLOSED )
		{
			std::cout << "lol ";
		}
	}

	// Remember whether each key is down or up
	if (event.EventType == irr::EET_KEY_INPUT_EVENT)
		KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;

	if (event.EventType == irr::EET_MOUSE_INPUT_EVENT)
	{
		switch(event.MouseInput.Event)
		{
		case EMIE_LMOUSE_PRESSED_DOWN:
			MouseState.LeftButtonDown = true;
			break;

		case EMIE_LMOUSE_LEFT_UP:
			MouseState.LeftButtonDown = false;
			break;

		case EMIE_MOUSE_MOVED:
			this->MouseState.deltaPosition.X = event.MouseInput.X - this->MouseState.Position.X;
			this->MouseState.deltaPosition.Y = event.MouseInput.Y - this->MouseState.Position.Y;

			MouseState.Position.X = event.MouseInput.X;
			MouseState.Position.Y = event.MouseInput.Y;
			break;

		default:
			// We won't use the wheel
			break;
		}
	}

	return false;
}
//------------------------------------------------------------------------
bool InputEventReceiver::IsKeyDown(EKEY_CODE keyCode) const
{
	return KeyIsDown[keyCode];
}
//------------------------------------------------------------------------
const InputEventReceiver::SMouseState & InputEventReceiver::GetMouseState(void) const
{
	return MouseState;
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------

